<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="http://code.jquery.com/jquery-1.12.1.min.js"></script>
</head>
<body>
<input id="p1" value=""/>
<input id="p2"/>
<button onclick="test();">确认</button>
</body>
<script>
    function test() {
        var p1 = $("#p1").val();
        var p2 = $("#p2").val();
        console.log(p1);
        console.log(p2);
        console.log(Math.abs(parseInt(p1) - parseInt(p2)));

        if (parseInt(p1) > 21 || parseInt(p2) > 21) {
            if (Math.abs(parseInt(p1) - parseInt(p2)) != 2) {
                alert("分数不符合规则");
            }
        }else{
            if(parseInt(p1) == 21 || parseInt(p2) == 21){
                if((parseInt(p1) == parseInt(p2)){
                    alert("分数不符合规则");
                }else {
                    alert("true");
                }
            }else {
                alert("分数不符合规则");
            }
        }


    }

</script>
</html>